package com.education.business.mapper.education;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.education.model.dto.TestPaperInfoDto;
import com.education.model.dto.TestPaperQuestionDto;
import com.education.model.entity.QuestionInfo;
import com.education.model.entity.TestPaperInfo;
import com.education.model.request.TestPaperQuestionRequest;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * @author zengjintao
 * @version 1.0
 * @create_at 2020/11/20 21:27
 */
public interface TestPaperInfoMapper extends BaseMapper<TestPaperInfo> {

    /**
     * 试卷分列表
     * @param page
     * @param testPaperInfo
     * @return
     */
    Page<TestPaperInfoDto> selectPageList(Page<TestPaperInfoDto> page, TestPaperInfo testPaperInfo);

    /**
     * 试卷试题列表
     * @param page
     * @param testPaperQuestionRequest
     * @return
     */
    Page<TestPaperQuestionDto> selectPaperQuestionList(Page<TestPaperQuestionDto> page, TestPaperQuestionRequest testPaperQuestionRequest);


    /**
     * 更新试卷参考人数
     * @param id
     * @return
     */
    @Update("update test_paper_info set exam_number = exam_number + 1 where id = #{id}")
    boolean updateExamNumberById(@Param("id") Integer id);

    @Select(" select paper.*, subject.name subject_name, grade.name gradeInfoName from test_paper_info paper\n" +
            "        left join grade_info grade on paper.grade_info_id = grade.id\n" +
            "        left join subject_info subject on paper.subject_id = subject.id WHERE paper.id=#{id}")
    TestPaperInfoDto getTestPaperInfoById(Integer id);

    TestPaperQuestionDto getTestPaperInfoByIdTwo(Integer id,Integer gradeInfoId,Integer subjectId);

    /**
     * 通过考试任务获取试卷列表
     */

    List<TestPaperInfoDto> getTestPaperListByExamTask(Integer examTaskId);

    /**
     * 2021
     */
    List<TestPaperInfo> testPaperInfoByTaskId(int taskId);
    int saveAll(TestPaperInfo testPaperInfo);
}
